class_name CollectableObject
extends Area2D

@onready var animator: AnimatedSprite2D = %Animator

@onready var asc: AbilitySystemComponent = %AbilitySystemComponent


func _ready() -> void:
	area_entered.connect(_on_area_entered)
	animator.play("idle")


func _on_area_entered(area: Area2D) -> void:
	var target = area.get_parent() as GameplayObject
	if target:
		asc.ability_manager.activate_ability("gain_score", target.asc)
		animator.play("collected")
		await animator.animation_finished
		queue_free()
